package cn.bdqn.service.impl;

import cn.bdqn.mapper.BrandMapper;
import cn.bdqn.pojo.Brand;
import cn.bdqn.service.BrandService;
import cn.bdqn.utils.RedisUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    @Resource
    BrandMapper brandMapper;
    @Resource
    RedisUtil redisUtil;
    @Override
    public List<Brand> selectAll() {
        List<Brand> o =(List<Brand>) redisUtil.get("brands");
        if(o==null){
            List<Brand> brands = brandMapper.selectAll1();
            redisUtil.set("brands",brands);
            return brands;
        }else{
            return o;
        }

    }
}
